home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / library / hack99 / frame_spoof.txt < prev    next >
Encoding:
Internet Message Format  |  1999-03-24  |  2.9 KB

  1. Date: Thu, 18 Feb 1999 10:36:49 PST
  2. From: Robert Thomas <offerrob@HOTMAIL.COM>
  3. To: BUGTRAQ@netspace.org
  4. Subject: Re: Netscape Communicator window spoofing bug
  5.  
  6. -Junk deleted-
  7.  
  8. This was reported back in the November, December time frame by
  9. secureexperts.com as a frame spoof bug.  MS came up with a lame patch
  10. for IE (that didn't work for all cases BTW).  The solution to this was
  11. provided to a US Government Agency by a contractor.  The agency has a
  12. high public trust and visibility and this was a concern.  Any questions
  13. can be addressed to krawls@erols.com.  The consultant came up with the
  14. following:
  15.  
  16. On the page being called up in the window i.e. the page
  17. to be protected should contain the following (frames or not):
  18.  
  19.  
  20. <SCRIPT LANGUAGE="JavaScript">
  21.  
  22. <!--
  23.  
  24. checkMyFramesMulti();
  25.  
  26. function ErrorHandler(errorMessage,url,line)
  27. {
  28.   spoofDetected("  Error message: "+
  29.          errorMessage+
  30.         "\n  Line number: "+
  31.          line, "TOP", url);
  32.   return true;
  33. }
  34.  
  35. onerror = ErrorHandler;
  36.  
  37. function checkMyFramesMulti()
  38. {
  39.   checkMyFrames();
  40.   setTimeout("checkMyFramesMulti()", 15000);
  41.  
  42. }
  43.  
  44. function checkMe()
  45. {
  46.   setTimeout("checkMyFrames()", 3000);
  47.  
  48. }
  49.  
  50. function checkMyFrames()
  51. {
  52.   var browsername = navigator.appName;
  53.   var browserversion = parseInt(navigator.appVersion);
  54.   var itsok;
  55.   var frameUrl;
  56.   var numFrames;
  57.   var i;
  58.  
  59.   if( (browsername == "Netscape") && (browserversion >= 3) )
  60.   {
  61.     if( self.opener != null )
  62.       spoofDetected(" OPENER NOT NULL!!", "TOP", "self.opener");
  63.   }
  64.  
  65.  
  66.   frameUrl = location.href;
  67.   itsok = urlOk(frameUrl);
  68.   if(  itsok.indexOf("false") == 0 )
  69.        spoofDetected(" Top is bad!!", "TOP", frameUrl);
  70.  
  71.   numFrames = self.frames.length;
  72.  
  73.   for( i = 0; i < numFrames; i++ )
  74.   {
  75.      frameUrl = self.frames[i].location.href;
  76.      itsok = urlOk(frameUrl);
  77.      if(  itsok.indexOf("false") == 0 )
  78.         spoofDetected(" This frame is bad!!", i, frameUrl);
  79.   }
  80.  
  81.  
  82. }
  83.  
  84. function urlOk(frameUrl)
  85. {
  86.   var thismany = parseInt(getAuthInfoNum());
  87.   var itsok = "false";
  88.   var Url;
  89.   var i;
  90.   for( i = 0; i < thismany; i++)
  91.   {
  92.     Url = getAuthInfo(i);
  93.     if(frameUrl.indexOf(Url) == 0)
  94.         itsok = "true";
  95.   }
  96.   return itsok;
  97. }
  98.  
  99. function spoofDetected(msg, frm, theUrl)
  100. {
  101.   var browsername = navigator.appName;
  102.   var browserversion = parseInt(navigator.appVersion);
  103.  
  104.   if( (browsername == "Netscape") && (browserversion >= 3) )
  105.   {
  106.     if( self.opener != null )
  107.       self.opener = null;
  108.   }
  109.   // spoofpage.html is an error page that gets pulled up on
  110.   // detection of an error.
  111.  
  112.   top.location.href = "spoofpage.html";
  113.  
  114. }
  115.  
  116.  function getAuthInfo(whichone) {
  117.  var legalUrls = new
  118. Array('http://www.agency.gov','http://www.agency.gov/left.html','http://www.agency.gov/top.html','http://www.agency.gov/main.ht
  119. ml');
  120.  return legalUrls[whichone];
  121.  }
  122.  
  123.  function getAuthInfoNum() {
  124.   return 4;
  125.  }
  126. // -->
  127.  
  128. </SCRIPT>
  129.  
  130.  
  131.  
  132. In the framed page add the onUnload command:
  133.  
  134. <BODY BGCOLOR="#FFFFFF" onUnload="parent.checkMe()">
  135.  
  136.